import type { RouteRecordRaw } from 'vue-router'
import type { Component } from 'vue'
import utils from '@/utils'

// views文件夹下的所有TSX文件自动生成映射关系
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
/**
 * Basic page
 */
const basePage: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/layouts/content'),
    children: [
      {
        path: '/home',
        component: () => import('@/layouts/content')
      }
    ]
  },
  {
    path: '/test',
    component: components['test']
  },
  {
    path: '/:pathMatch(.*)',
    component: () => import('@/layouts/content')
  }
]

/**
 * Login page
 */
const loginPage: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    component: components['login'],
    meta: {
      auth: []
    }
  }
]

const routes: RouteRecordRaw[] = [...basePage, ...loginPage]

// 重新组织后导出
export default routes
